package com.leslie.hhcommunity.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * @author
 * @PackageName:com.leslie.hhcommunity.entity
 * @ClassnName:DiscussPost
 *
 * 使用@Document将实体和索引（也就是数据库中的表）相联系，使用@Id设置索引中哪个字段为id，@Field来设置索引中的字段。
 * 其中@Document中indexName表示索引名字，shards表示分片，replicas表示副本数量
 *
 * @Description: 帖子实体类
 * @Date 2021/12/31  15:23
 */
@Document(indexName = "discusspost", shards = 6, replicas = 3)
public class DiscussPost {
	@Id
	private int id;
	@Field(type = FieldType.Integer)
	private int userId;
	//analyzer表示解析器，ik_max_word表示将一句话拆分成尽可能多的词语，ik_smart表示符合尝试的解析器
	@Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
	private String title;
	@Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
	private String content;
	@Field(type = FieldType.Integer)
	private int type;
	@Field(type = FieldType.Integer)
	private int status;
	@Field(type = FieldType.Date)
	private Date createTime;
	@Field(type = FieldType.Integer)
	private int commentCount;
	@Field(type = FieldType.Double)
	private double score;

	public DiscussPost() {
	}

	public DiscussPost(int id, int userId, String title, String content, int type, int status, Date createTime, int commentCount, double score) {
		this.id = id;
		this.userId = userId;
		this.title = title;
		this.content = content;
		this.type = type;
		this.status = status;
		this.createTime = createTime;
		this.commentCount = commentCount;
		this.score = score;
	}

	public int getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(int commentCount) {
		this.commentCount = commentCount;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public double getScore() {
		return score;
	}

	public void setScore(double score) {
		this.score = score;
	}

	@Override
	public String toString() {
		return "DiscussPost{" +
				"id=" + id +
				", userId=" + userId +
				", title='" + title + '\'' +
				", content='" + content + '\'' +
				", type=" + type +
				", status=" + status +
				", createTime=" + createTime +
				", score=" + score +
				'}';
	}
}
